package uno;

import java.util.*;

public class CaraOCruz {

	public static void main(String[] args) {

		int N, coin, John, Mary;
		int i;
		System.out.print("Ingresar cantidad de jugadas");
		Scanner in = new Scanner(System.in);

		while (true) {
			N = in.nextInt();

			if (N == 0)
				break;
			John = Mary = 0;

			for (i = 0; i < N; i++) {
				coin = in.nextInt();

				if (coin == 1)
					John++;
				else
					Mary++;
			}
			System.out.println("Mary won " + Mary + " times and John won "
					+ John + " times ");
		}
	}

}